<script>
var _siteUrl = '<?php echo  Yii::app()->params['siteUrl']?>';

$(function() {
	var validator = $("#form1").validate({
		rules: {
			name: "required",
			manager_unique_id: "required",
			manager: "required"
		},
		messages: {
			name: {
				required: "请输入名称！",
			},
			manager_unique_id: {
				required: "请输入主管工号！",
			},
			manager: {
				required: "请输入主管名！",
			}
		},
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				error.appendTo( element.parent().next() );
		},
		submitHandler: function(form) {
			$("#form_submit").attr("disabled","disabled");
			form.submit();
		}
	});
});
</script>
<?php
/* @var $this DepartmentController */
/* @var $model UserDepartment */
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/global/js/pages/department.js");
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . "/global/js/plugins/jquery.validate.js");
$this->breadcrumbs=array(
	'User Departments'=>array('index'),
	$model->name=>array('view','id'=>$model->id),
	'更新',
);

?>

<span class="page_h3">更新 部门 <?php echo $model->id . $model->name; ?></span>

<form action="#" method="post" name="" id="form1"  >
    <table cellpadding="1" cellspacing="1" class="c_table">
        <tr class="r1">
            <td class='c_row0' width="120" align="right">名称：</td>
            <td width="420px;"><input type="text" name="name" id="name" class="small_input" value="<?php echo $model->name; ?>" /><span class="red">*</span></td>
            <td class="red"></td> 
        </tr>
        <tr class="r2">
            <td class='c_row0' align="right">父节点：</td>
            <td colspan="2">
            <?php 
				echo CHtml::dropDownList('parent_id_1' ,$departmentOptionsVal[1] ,$departmentOptions[1],array('onchange'=>'department.showDepartment(1);','class'=>'mid_select2 ')); 
			?>
            <?php 
			if(isset($departmentOptionsVal[2]))
				echo CHtml::dropDownList('parent_id_2' ,$departmentOptionsVal[2] ,$departmentOptions[2],array('onchange'=>'department.showDepartment(2);','class'=>'mid_select2 ')); 
			else
				echo '<select name="parent_id_2" id="parent_id_2" class="mid_select2 " onchange="department.showDepartment(2);">
                 <option value="0">2级</option>
            </select>';
			?>
            <?php 
			if(isset($departmentOptionsVal[3]))
				echo CHtml::dropDownList('parent_id_3' ,$departmentOptionsVal[3] ,$departmentOptions[3],array('onchange'=>'department.showDepartment(3);','class'=>'mid_select2 bg_orange')); 
			else
				echo '<select name="parent_id_3" id="parent_id_3" class="mid_select2 " onchange="department.showDepartment(3);">
                 <option value="0">3级</option>
            </select>';	
			?>
            <input type="hidden" id="level" name="level" value="<?php echo $model->level; ?>>" />
            </td>
        </tr>
        <tr class="r1">
            <td class='c_row0' align="right">主管名(邮箱前缀)：</td>
            <td><input type="text" name="manager" id="manager" class="small_input" value="<?php echo $model->manager?>"><span class="red">*</span></td>
            <td class="red"></td>
        </tr>
        <tr class="r2">
            <td class='c_row0' align="right">主管工号：</td>
            <td><input type="text" name="manager_unique_id" id="manager_unique_id" class="small_input" value="<?php echo $model->manager_unique_id?>"><span class="red">*</span></td>
            <td class="red"></td>
        </tr>
        
        <tr class="r1">
            <td class='c_row0' align="right">状态： </td>
            <td>
            <?php echo CHtml::dropDownList('status' ,$model->status ,$statusOption,array('class'=>'mid_select2')); ?>
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r2">
            <td class='c_row0' align="right">是否是项目组： </td>
            <td>
            <?php echo CHtml::dropDownList('project_group' ,$model->project_group ,$ynOption,array('class'=>'mid_select2')); ?>
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r1">
            <td class='c_row0' align="right">是否显示： </td>
            <td>
            <?php echo CHtml::dropDownList('display' ,$model->display,$ynOption,array('class'=>'mid_select2')); ?>
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r2">
            <td class='c_row0' align="right">部门属性： </td>
            <td>   
            <?php echo CHtml::dropDownList('attribute' ,$model->attribute ,$attrOption,array('class'=>'mid_select2')); ?>
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r1">
            <td class='c_row0' align="right">行政助理： </td>
            <td>   
            <input type="text" name="admin_assistant" id="admin_assistant" class="small_input" value="<?php echo $model->admin_assistant; ?>" />
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r2">
            <td class='c_row0' align="right">HR招聘专员： </td>
            <td>   
            <input type="text" name="hr_assistant" id="hr_assistant" class="small_input " value="<?php echo $model->hr_assistant; ?>" />
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r1">
            <td class='c_row0' align="right">奖金发放形式： </td>
            <td>   
            
            </td>
            <td class="red"></td>
        </tr>
        <tr class="r2">
            <td class='c_row0'></td>
            <td>
                <input type="hidden" name="id" id="id" value="<?php echo $model->id; ?>" />
                <input type="hidden" name="action" id="" value="update" />
                <input type="hidden" value="<?php echo Yii::app()->request->csrfToken; ?>"  name="YII_CSRF_TOKEN" />
                <input type="submit" name="fsubmit" id="form_submit" class="button_grey" value=" 确 定 " />
                <input type="button" name="r" value=" 关 闭 " class="button_grey" onclick="javascript:if(confirm('确定关闭本页？'))window.close();" />
            </td>
            <td></td>
        </tr>
    </table>

</form>
